//
//  UIDevice+Extension.swift
//  MattressTool
//
//  Created by Coder Yang on 2023/11/19.
//

import UIKit

extension UIDevice {
    
    /// 顶部安全区高度
   static var topSafeArea: CGFloat {
        guard
            let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
            let window = scene.windows.first else {
            return 0
        }
        return window.safeAreaInsets.top
    }
    
    /// 底部安全区高度
    static var bottomSafeArea: CGFloat {
        guard
            let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
            let window = scene.windows.first else {
            return 0
        }
        return window.safeAreaInsets.bottom
    }
    
    /// 状态栏高度
    static var statusBarHeight: CGFloat {
        guard
            let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
            let barManager = scene.statusBarManager else {
            return 0
        }
        return barManager.statusBarFrame.height
    }
    
    /// 导航高度
    static var navigationBarHeight: CGFloat {
        44.0
    }
    
    /// 导航栏高度
    static var navBarHeight: CGFloat {
        topSafeArea + navigationBarHeight
    }
    
    /// 底部选项卡高度
    static var tabBarHeight: CGFloat {
        49.0
    }
    
    /// 底部选项卡高度 + 安全区域高度
    static var tabBarSafeHeight: CGFloat {
        tabBarHeight + bottomSafeArea
    }
}
